from PIL import Image

img_path = "../pic/pillow/car_a_200.jpg"
image = Image.open(img_path)  # 二值化后的图片
image.getcolors()
rgb_start = image.getcolors()[0]
rgb_end = image.getcolors()[-1]
rgb_start_color, rgb_end_color = rgb_start[1], rgb_end[1]
rgb_start_int, rgb_end_int = rgb_start[0], rgb_end[0]

print(rgb_start, rgb_end)
if rgb_start_int > rgb_end_int:
    if rgb_start_color == 0 or rgb_start_color == (0, 0, 0):
        print("黑底白字")
else:
    if rgb_start_color == 255 or rgb_start_color == (255, 255, 255):
        print("黑底白字 %s" % rgb_start_int)
